<!--
 * @Descripttion: 网站入口-首页
 * @Author: xinqiao lxq1990.0716@qq.com
 * @Date: 2025-06-06
 * @LastEditors: xinqiao lxq1990.0716@qq.com
 * @LastEditTime: 2025-06-12
-->
<script lang="ts" setup>
  import { onMounted, ref } from 'vue'

  import { CommonImgEnum, HomeImgEnum } from '/@/enums/imageEnum'

  /** 搜索文本 */
  const searchText = '数据采集等动态关键词展示'

  /** 搜索框值 */
  const searchValue = ref('')

  /** 循环器 */
  let interval

  /**
   * 循环写入文本
   */
  const loopWrite = () => {
    interval = setInterval(() => {
      if (searchValue.value.length >= searchText.length) {
        clearInterval(interval)
        interval = undefined
        setTimeout(() => {
          searchValue.value = ''
          loopWrite()
        }, 5000)
      } else {
        searchValue.value += searchText[searchValue.value.length]
      }
    }, 150)
  }

  onMounted(() => loopWrite())
</script>

<template>
  <div class="home">
    <video class="bg" :src="HomeImgEnum.bg" autoplay muted loop preload="metadata"></video>
    <div class="search">
      <img class="search-icon" :src="HomeImgEnum.searchIcon" />
      <div class="search-input">
        <span class="search-input-text">{{ searchValue }}</span>
        <span class="search-input-cursor"></span>
      </div>
      <!-- <input class="search-input" type="text" v-model="searchValue" /> -->
      <span class="search-btn">
        <span class="search-btn-text">加入生态</span>
        <img class="search-btn-arrow" :src="CommonImgEnum.searchArrow" />
      </span>
    </div>
    <div class="step">
      <img class="step-icon" :src="HomeImgEnum.stepCollection" />
      <span class="step-name">数据采集</span>
      <img class="step-arrow" :src="HomeImgEnum.stepArrow" />
      <img class="step-icon" :src="HomeImgEnum.stepConfirm" />
      <span class="step-name">数据确权</span>
      <img class="step-arrow" :src="HomeImgEnum.stepArrow" />
      <img class="step-icon" :src="HomeImgEnum.stepGovern" />
      <span class="step-name">数据治理</span>
      <img class="step-arrow" :src="HomeImgEnum.stepArrow" />
      <img class="step-icon" :src="HomeImgEnum.stepFlow" />
      <span class="step-name">数据流通</span>
      <img class="step-arrow" :src="HomeImgEnum.stepArrow" />
      <img class="step-icon" :src="HomeImgEnum.stepProcess" />
      <span class="step-name">要素加工</span>
      <img class="step-arrow" :src="HomeImgEnum.stepArrow" />
      <img class="step-icon" :src="HomeImgEnum.stepValue" />
      <span class="step-name">价值实现</span>
    </div>
  </div>
</template>

<style lang="less" scoped>
  .home {
    position: relative;
    margin-top: -60px;

    .bg {
      width: 100%;
    }

    .search {
      position: absolute;
      z-index: 1;
      top: 404px;
      left: 80px;
      width: 512px;
      height: 75px;
      display: flex;
      align-items: center;
      border: 1px solid #d4dae6;
      border-radius: 38px;
      background: rgb(255 255 255 / 75%);

      .search-icon {
        width: 24px;
        height: 24px;
        margin-left: 20px;
      }

      .search-input {
        display: flex;
        width: 288px;
        height: 26px;
        margin-left: 16px;
        outline: none;

        .search-input-text {
          height: 26px;
          line-height: 26px;
          font-size: 18px;
          font-weight: 500;
          color: #111;
        }

        .search-input-cursor {
          width: 2px;
          height: 26px;
          background: #333;
          margin: 1px 0 0 4px;
          animation: twinkle 1s infinite;
        }
      }

      .search-btn {
        display: flex;
        justify-content: center;
        align-items: center;
        width: 154px;
        height: 55px;
        border-radius: 30px;
        background: linear-gradient(270deg, #39bffc 0%, #246af3 94.05%);
        cursor: pointer;

        .search-btn-text {
          width: 72px;
          font-size: 18px;
          font-weight: 500;
          color: #fff;
        }

        .search-btn-arrow {
          width: 22px;
          height: 22px;
          margin-left: 8px;
        }
      }
    }

    .step {
      position: absolute;
      z-index: 1;
      bottom: 80px;
      left: 0;
      right: 0;
      margin: auto;
      width: 1620px;
      height: 120px;
      display: flex;
      justify-content: center;
      align-items: center;
      border: 2px solid #fff;
      border-radius: 20px;
      background: rgb(255 255 255 / 80%);

      .step-icon {
        width: 48px;
        height: 48px;
      }

      .step-name {
        margin-left: 16px;
        font-size: 24px;
        color: #1d2129;
      }

      .step-arrow {
        margin: 0 26px;
        width: 48px;
        height: 20px;
      }
    }
  }

  @keyframes twinkle {
    0% {
      opacity: 0;
    }

    49% {
      opacity: 0;
    }

    50% {
      opacity: 1;
    }

    100% {
      opacity: 1;
    }
  }
</style>
